//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.guideshow;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;

import com.base.app_core.base.ActionPacketView;
import com.gyf.barlibrary.ImmersionBar;

import java.util.List;

public abstract class AbsGuideActivity extends FragmentActivity {

    protected ImmersionBar mImmersionBar;

    public AbsGuideActivity() {
    }
    abstract protected ActionPacketView.GuideViewPagerChange getGuideViewPager();
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        List<SinglePage> guideContent = this.buildGuideContent();
        if (guideContent != null) {
            FrameLayout container = new FrameLayout(this);
            ViewPager pager = new ViewPager(this);
            pager.setId(this.getPagerId());
            container.addView(pager, new LayoutParams(-1, -1));
            this.setContentView(container);
            FragmentPagerAdapter adapter = new FragmentTabAdapter(this, guideContent);
            pager.setAdapter(adapter);
            GuideView guideView = new GuideView(this, guideContent, this.drawDot(), this.dotDefault(), this.dotSelected());
            guideView.setGuideViewPager(getGuideViewPager());
            pager.setOffscreenPageLimit(0);//不预先加载下一界面
            pager.setOnPageChangeListener(guideView);
            container.addView(guideView, new android.widget.FrameLayout.LayoutParams(-1, -1));
        }
        initImmersionBar();
    }

    protected void initImmersionBar() {
        //在BaseActivity里初始化
        mImmersionBar = ImmersionBar.with(this).fitsSystemWindows(true).statusBarColor(com.base.app_core.R.color.head_color);
        mImmersionBar.init();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mImmersionBar != null)
            mImmersionBar.destroy();  //在BaseActivity里销毁
    }

    public abstract List<SinglePage> buildGuideContent();

    public abstract boolean drawDot();

    public abstract Bitmap dotDefault();

    public abstract Bitmap dotSelected();

    public abstract int getPagerId();
}
